package lt.liepasoft.sudoku.component;

import java.util.Map;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class PaintGrid extends PaintComponent {

	public PaintGrid(Map<Data, Integer> options) {
		super(options);
		paint = new Paint();
		paint.setColor(Color.LTGRAY);
		paint.setStrokeWidth(options.get(Data.LINE_STROKE_WIDTH));
	}

	@Override
	public void paint(Canvas canvas) {
		paint.setStrokeWidth(options.get(Data.LINE_STROKE_WIDTH));
		for (int i=0; i<10; i++) {
			//horizontal lines
			canvas.drawLine(
					options.get(Data.GRID_OFFSET_X), 
					options.get(Data.GRID_OFFSET_Y)+(options.get(Data.CELL_WIDTH)*i),
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*9), 
					options.get(Data.GRID_OFFSET_Y)+(options.get(Data.CELL_WIDTH)*i), 
					paint);
			
			//vertical lines
			canvas.drawLine(
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*i), 
					options.get(Data.GRID_OFFSET_Y),
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*i), 
					options.get(Data.GRID_OFFSET_Y)+options.get(Data.CELL_WIDTH)*9, 
					paint);						
		}
		
		paint.setStrokeWidth(options.get(Data.LINE_STROKE_WIDTH)+3);
		for (int i=0; i<4; i++) {
			//horizontal lines
			canvas.drawLine(
					options.get(Data.GRID_OFFSET_X), 
					options.get(Data.GRID_OFFSET_Y)+(options.get(Data.CELL_WIDTH)*3*i),
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*9), 
					options.get(Data.GRID_OFFSET_Y)+(options.get(Data.CELL_WIDTH)*3*i), 
					paint);
			
			//vertical lines
			canvas.drawLine(
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*3*i), 
					options.get(Data.GRID_OFFSET_Y),
					options.get(Data.GRID_OFFSET_X)+(options.get(Data.CELL_WIDTH)*3*i), 
					options.get(Data.GRID_OFFSET_Y)+options.get(Data.CELL_WIDTH)*9, 
					paint);						
		}		
	}

}
